<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%--
  Created by Petro 24.03.13 21:20
--%>
<table>
    <tbody>
        <c:forEach var="message" items="${list}">
            <tr>
                <td onclick="document.location='/users/${message.sender.id}';" style="cursor: pointer">
                    <c:choose>
                        <c:when test="${not empty message.sender.photo}">
                            <img src="${pageContext.request.contextPath}/images?id=${message.sender.id}&size=30" alt="${message.sender.displayedShortName}">
                        </c:when>
                        <c:otherwise>
                            <img src="/resources/image/default_avatar_30.png" alt="${message.sender.displayedShortName}">
                        </c:otherwise>
                    </c:choose>
                </td>
                <td style="padding: 5px; cursor: pointer" onclick="document.location='/users/${message.sender.id}';"><c:out value="${message.sender.displayedShortName}"/></td>
                <td style="padding: 5px; cursor: pointer" onclick="document.location='/msg/${message.id}';"><c:out value="${message.sendDate}"/></td>
                <td style="padding: 5px; cursor: pointer" onclick="document.location='/msg/${message.id}';">
                    <c:if test="${not empty message.subject}">
                        <b><c:out value="${message.subject}"/></b><br>
                    </c:if>
                    <c:out value="${message.body}"/>
                </td>
            </tr>
        </c:forEach>
    </tbody>
</table>